package com.frank.biz.wjwfal.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.biz.wjwfal.domain.BizWjwfal;
import com.frank.biz.wjwfal.service.IBizWjwfalService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 违纪违法案例Controller
 * 
 * @author frank
 * @date 2024-09-10
 */
@Controller
@RequestMapping("/biz/wjwfal")
public class BizWjwfalController extends BaseController
{
    private String prefix = "biz/wjwfal";

    @Autowired
    private IBizWjwfalService bizWjwfalService;

    @RequiresPermissions("biz:wjwfal:view")
    @GetMapping()
    public String wjwfal()
    {
        return prefix + "/wjwfal";
    }

    /**
     * 查询违纪违法案例列表
     */
    @RequiresPermissions("biz:wjwfal:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizWjwfal bizWjwfal)
    {
        startPage();
        bizWjwfal.setCreateBy(getLoginName());
        List<BizWjwfal> list = bizWjwfalService.selectBizWjwfalList(bizWjwfal);
        return getDataTable(list);
    }

    /**
     * 导出违纪违法案例列表
     */
    @RequiresPermissions("biz:wjwfal:export")
    @Log(title = "违纪违法案例", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizWjwfal bizWjwfal)
    {
        bizWjwfal.setCreateBy(getLoginName());
        List<BizWjwfal> list = bizWjwfalService.selectBizWjwfalList(bizWjwfal);
        ExcelUtil<BizWjwfal> util = new ExcelUtil<BizWjwfal>(BizWjwfal.class);
        return util.exportExcel(list, "违纪违法案例数据");
    }

    /**
     * 新增违纪违法案例
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存违纪违法案例
     */
    @RequiresPermissions("biz:wjwfal:add")
    @Log(title = "违纪违法案例", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizWjwfal bizWjwfal)
    {
        bizWjwfal.setCreateBy(getLoginName());
        return toAjax(bizWjwfalService.insertBizWjwfal(bizWjwfal));
    }

    /**
     * 修改违纪违法案例
     */
    @RequiresPermissions("biz:wjwfal:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BizWjwfal bizWjwfal = bizWjwfalService.selectBizWjwfalById(id);
        mmap.put("bizWjwfal", bizWjwfal);
        return prefix + "/edit";
    }

    /**
     * 修改保存违纪违法案例
     */
    @RequiresPermissions("biz:wjwfal:edit")
    @Log(title = "违纪违法案例", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizWjwfal bizWjwfal)
    {
        bizWjwfal.setUpdateBy(getLoginName());
        return toAjax(bizWjwfalService.updateBizWjwfal(bizWjwfal));
    }

    /**
     * 删除违纪违法案例
     */
    @RequiresPermissions("biz:wjwfal:remove")
    @Log(title = "违纪违法案例", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizWjwfalService.deleteBizWjwfalByIds(ids));
    }
}
